#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> div(vector<int>& A,int b,int& r)
{
    vector<int> C;
    r = 0;
    for(int i = 0 ; i < A.size() ; ++i)
    {
        r = r * 10 + A[i];
        C.push_back(r / b);
        r %= b;
    }
    reverse(C.begin() , C.end());
    while(C.size() > 1 && C.back() == 0) C.pop_back();
    return C;
}
int main()
{
    string s1; int b;
    cin >> s1 >> b;
    vector<int> A,B;
    for(int i = 0 ; i < s1.size() ; ++i) A.push_back(s1[i]-'0');

    int r;//余数
    vector<int> C = div(A,b,r);
    for(int i = C.size() - 1 ; i >= 0 ; --i) printf("%d",C[i]);
    cout << endl;
    printf("%d\n",r);    
    return 0;
}